import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import *

testCase = "dbshopST020_后台删除属性"
# 1.点击“删除”按钮，确定删除，删除成功。
firefox = openBrowser(urlAdmin)
# 登录后台
DBshopLoginAdmin(firefox)
# 进入三级菜单
DBshopEnterMenu3(firefox, "商品管理", "商品属性", "属性")
firefox.find_element_by_xpath('//td[text()="天天向上"]/following-sibling::td[4]/a[3]').click()
firefox.switch_to.alert.accept()  # 点击确定按钮
time.sleep(5)
# 删除属性分组，防止下次执行脚本报错
DBshopEnterMenu3(firefox, "商品管理", "商品属性", "属性分组")
firefox.find_element_by_xpath('//td[text()="好好学习"]/following-sibling::td[2]/a[2]').click()
time.sleep(2)
firefox.switch_to.alert.accept()  # 点击确定按钮
time.sleep(2)
# 再次进入三级菜单
DBshopEnterMenu3(firefox, "商品管理", "商品属性", "属性")
# 断言
try:
    firefox.find_element_by_xpath('//td[text()="天天向上"]')
    writeLog("%s 测试失败" % testCase)
    getPhoto(firefox)
except:
    writeLog("%s 测试通过" % testCase)
firefox.quit()
